package com.wl156.activities.find;

import com.wl156.lite.R;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class PlaceInfo extends Activity implements OnClickListener {

	private TextView mName;
	private Button mShowInMap;

	String id;
	String name;
	String type;
	String business;
	String phone;
	String longitude;
	String latitude;
	String radius;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act_place_info);

		Bundle extras = getIntent().getExtras();
		this.id = extras.getString("id");
		this.name = extras.getString("name");
		this.type = extras.getString("type");
		this.business = extras.getString("business");
		this.phone = extras.getString("phone");
		this.longitude = extras.getString("longitude");
		this.latitude = extras.getString("latitude");
		this.radius = extras.getString("radius");

		TextView name = (TextView) findViewById(R.id.name);
		name.setText(this.name);
		TextView type = (TextView) findViewById(R.id.type);
		if (this.type.equals("A")) {
			type.setText("所有类型");
		} else if (this.type.equals("S")) {
			type.setText("服务点");
		} else {
			type.setText("优惠点");
		}
		TextView business = (TextView) findViewById(R.id.business);
		business.setText(this.business);
		TextView longitude = (TextView) findViewById(R.id.longitude);
		longitude.setText(this.longitude);
		TextView latitude = (TextView) findViewById(R.id.latitude);
		latitude.setText(this.latitude);
		TextView radius = (TextView) findViewById(R.id.radius);
		radius.setText(this.radius);

		Button call = (Button) findViewById(R.id.call);
		call.setOnClickListener(this);

		mShowInMap = (Button) findViewById(R.id.showInMap);
		mShowInMap.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.showInMap: {
			Intent i = new Intent(this, PlaceMap.class);
			// 03-08 21:40:28.523: D/(18721): location.longitude: 116.4735259,
			// latitude: 39.8834874

			i.putExtra("latitude", latitude);
			i.putExtra("longitude", longitude);
			i.putExtra("name", name);
			startActivity(i);
		}
			break;
		case R.id.call: {
			Intent i = new Intent(Intent.ACTION_CALL);
			i.setData(Uri.parse("tel:" + phone));
			startActivity(i);
		}
			break;
		}
	}
}
